package com.ruoyi.system.service.impl;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.config.datasource.DynamicDataSourceContextHolder;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.system.domain.vo.OrderLogVo;
import com.ruoyi.system.mapper.RyAdminMapper;
import com.ruoyi.system.service.IRyAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.sql.*;


@Service
public class RyAdminServiceImpl implements IRyAdminService {
    @Autowired
    private RyAdminMapper ryAdminMapper;


    @Override
    @DataSource(DataSourceType.SLAVE)
    @Transactional(propagation = Propagation.REQUIRES_NEW) // 开启新事务
    public int insertOrderLogVo(OrderLogVo orderLogVo) {
        return ryAdminMapper.insertOrderLogVo(orderLogVo);
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    @Transactional(propagation = Propagation.REQUIRES_NEW) // 开启新事务
    public int updateOrderLogVo(OrderLogVo orderLogVo) {
        return ryAdminMapper.updateOrderLogVo(orderLogVo);
    }
}
